from typing import List


class Solution:
    def countWays(self, nums: List[int]) -> int:
        nums.sort()
        # print(nums)
        c = 0
        for i in range(0, len(nums) + 1):
            # print(i)
            if i == 0:
                if i < nums[0]:
                    c += 1
            elif i == len(nums):
                if i > nums[-1]:
                    c += 1
            else:
                if nums[i - 1] < i < nums[i]:
                    c += 1
        return c


if __name__ == '__main__':
    nums = [6, 0, 3, 3, 6, 7, 2, 7]
    s = Solution()

    print(s.countWays(nums))
